package com.kingwang.training.designpattern.exam.config;

import com.kingwang.training.designpattern.exam.bo.event.EventBus;
import com.kingwang.training.designpattern.exam.bo.event.EventHandler;
import com.kingwang.training.designpattern.exam.bo.event.TaskCreatedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 事件注册器
 *
 * @author King
 */
@Component
public class EventRegister {
    @Resource
    private EventHandler<TaskCreatedEvent> taskCreatedEventEventHandler;

    @Resource
    private EventBus eventBus;

    /**
     * 初始化
     * 注册事件处理器
     */
    public void init() {
        this.eventBus.register(TaskCreatedEvent.class, this.taskCreatedEventEventHandler);
    }
}
